import 'package:flutter/material.dart' ;
import 'package:flutter/services.dart';
import 'package:mfkb/pages/fun.dart';
import 'package:mfkb/pages/home.dart';
import 'package:mfkb/pages/mine.dart';
import 'package:mfkb/pages/school.dart';

class NavitorBar extends StatefulWidget {
  @override
  _NavitorBarState createState() => _NavitorBarState();
}

class _NavitorBarState extends State<NavitorBar> {

  var _currentIndex = 0 ;
  List _list = [] ;

  @override
  void initState() {
    _list
      ..add(Home())
      ..add(FunWidget()) 
      ..add(School())
      ..add(Mine()) ;
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return AnnotatedRegion<SystemUiOverlayStyle>(
      child: Scaffold(
        body: _list[_currentIndex],
        bottomNavigationBar: BottomNavigationBar(
          elevation: 0,
          backgroundColor: Colors.white,
          fixedColor: Color.fromARGB(255, 0, 195, 206),
          type: BottomNavigationBarType.fixed,
          items: <BottomNavigationBarItem>[
            BottomNavigationBarItem(
              icon: Image.asset("assets/images/today.png" , width:28.0 , height:28.0 , fit: BoxFit.fill,) ,
              activeIcon: Image.asset("assets/images/today_active.png", width:28.0 , height:28.0 , fit: BoxFit.fill,) ,
              title: Text("今日") ,
            ) ,
            BottomNavigationBarItem(
              icon: Image.asset("assets/images/fun.png", width:28.0 , height:28.0 , fit: BoxFit.fill,) ,
              activeIcon: Image.asset("assets/images/fun_active.png", width:28.0 , height:28.0 , fit: BoxFit.fill,) ,
              title: Text("功能")
            ) ,
            BottomNavigationBarItem(
              icon: Image.asset("assets/images/school_.png", width:28.0 , height:28.0 , fit: BoxFit.fill,) ,
              activeIcon: Image.asset("assets/images/school_active.png", width:28.0 , height:28.0 , fit: BoxFit.fill,) ,
              title: Text("校园")
            ) ,
            BottomNavigationBarItem(
              icon: Image.asset("assets/images/mine.png", width:28.0 , height:28.0 , fit: BoxFit.fill,) ,
              activeIcon: Image.asset("assets/images/mine_active.png", width:28.0 , height:28.0 , fit: BoxFit.fill,) ,
              title: Text("我的")
            ) ,
          ],
          currentIndex: _currentIndex,
          onTap: (index) {
            setState(() {
              _currentIndex = index ;
            });
          },
        ),
      ) ,
      value: SystemUiOverlayStyle.dark,
    );
  }
}